package com.czk.provider;

import com.czk.framework.Protocol;
import com.czk.framework.URL;
import com.czk.protocol.dubbo.DubboProtocol;
import com.czk.protocol.http.HttpProtocol;
import com.czk.provider.api.HelloService;
import com.czk.provider.impl.HelloServiceImpl;
import com.czk.register.ConsumerRegisterCache;
import com.czk.register.RemoteRegister;
import com.czk.register.ZookeeperRegister;

import java.io.IOException;

/**
 * 启动类
 *
 * @Author:ChenZhangKun
 * @Date: 2021/4/14 16:10
 */
public class Provider {
    public static void main(String[] args) throws IOException {
        // 本地注册
        LocalRegister.register(HelloService.class.getName(), HelloServiceImpl.class);
        // 远程注册
        RemoteRegister.register(HelloService.class.getName(), new URL("localhost", 8080));
        // zookeeper注册
      /*  ZookeeperRegister.register(HelloService.class.getName(), new URL("localhost", 8080));
        ZookeeperRegister.register(HelloService.class.getName(), new URL("localhost", 8081));*/
        // netty ->server1
        Protocol nettyServer = new DubboProtocol();
        // 启动httpServer ->server2
        Protocol httpServer = new HttpProtocol();
        //HttpServer httpServer = new HttpServer();
         nettyServer.start(new URL("localhost", 8080));
        // httpServer.start(new URL("localhost", 8081));
    }
}
